@extends('base.base')
@section('base')
    <!-- 内容区域 -->
    <div class="main-panel">
        <div class="content-wrapper">
            <div class="row">
                <div class="col-12 grid-margin stretch-card">
                    <div class="card">
                        <div class="card-body">
                            <h4 class="card-title">修改应用信息</h4>
                            {{--<p class="card-description">--}}
                            {{--Basic form elements--}}
                            {{--</p>--}}
                            <form class="forms-sample" id="form">
                                <div class="form-group">
                                    <label >* 应用名称</label>
                                    <input type="text"  class="form-control required" name="name" placeholder="应用名称" value="{{ $config->name }}">
                                </div>
                                @if(session('admin')->hasSuperRole())
                                <div class="form-group">
                                    <label >* 所属用户 <span style="color:red">(多个用户的话，用英文,逗号隔开)</span></label>
                                    <input type="text"  class="form-control required" name="user_id" placeholder="" value="{{ $config->user_id }}">
                                </div>
                                @endif
                                <div class="form-group">
                                    <label > 手机号（方便短信通知）</label>
                                    <input type="text"  class="form-control" name="mobile" placeholder="输入手机号，方便命中短信提醒" value="{{ $config->mobile }}" />
                                </div>
                                <div class="form-group" id="image">
                                    <label> 图标</label>
                                    <input type="file" class="file-upload-default img-file" data-path="app-icon">
                                    <input type="hidden" class="image-path value-input" name="icon_url" value="{{ $config->icon_url }}">
                                    <div class="input-group col-xs-12">
                                        <input type="text" class="form-control file-upload-info" disabled="" value="{{ $config->icon_url }}">
                                        <span class="input-group-append">
                                            <button class="file-upload-browse btn btn-gradient-primary" onclick="upload($(this))" type="button">上传</button>
                                        </span>
                                    </div>
                                    <div class="img-yl" style="display: block;">
                                        <img src="{{ $config->icon_url }}" alt="">
                                    </div>
                                </div>
                                <div class="form-group">
                                    <label >* 黑名单命中对应跳转链接</label>
                                    <input type="text"  class="form-control required" name="redirect_url" placeholder="填写跳转链接" value="{{ $config->redirect_url }}">
                                </div>
                                <div class="form-group">
                                    <label > 口子参数</label>
                                    <input type="text"  class="form-control" name="query_param" placeholder="口子参数 例如 code=123&name=毛" value="{{ $config->query_param }}">
                                </div>
                                @if(session('admin')->hasSuperRole())
                                <div class="form-group">
                                    <label > 是否加签名跳转</label>
                                    <div class="row" style="margin-left: 10px;">
                                        <div class="form-check col-2">
                                            <label class="form-check-label">
                                                <input type="radio" name="redirect_switch" class="form-radio-input td-radio" value="1" @if($config->redirect_switch == 1) checked @endif>是
                                            </label>
                                        </div>
                                        <div class="form-check col-2">
                                            <label class="form-check-label">
                                                <input type="radio" name="redirect_switch" class="form-radio-input td-radio" value="0" @if($config->redirect_switch == 0) checked @endif>否
                                            </label>
                                        </div>
                                    </div>
                                </div>
                                @endif
                                <button type="button" onclick="commit({{ $config->id }})" class="btn btn-sm btn-gradient-primary btn-icon-text">
                                    <i class="mdi mdi-file-check btn-icon-prepend"></i>
                                    提交
                                </button>
                                <button type="button" onclick="cancel()" class="btn btn-sm btn-gradient-warning btn-icon-text">
                                    <i class="mdi mdi-reload btn-icon-prepend"></i>
                                    取消
                                </button>
                            </form>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>
        function commit(id){
            if(!checkForm()){
                return false;
            }
            var data = $("#form").serializeObject();
            myRequest("/admin/app/update/"+id,"post",data,function(res){
                layer.msg(res.msg)
                setTimeout(function(){
                    parent.location.reload();
                },1500)
            });
        }
        function cancel() {
            parent.location.reload();
        }
    </script>
@endsection
